#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;

int main()
{
    IOS;
    ll n;
    while(cin>>n&&n){
        ll num;
        ll pre=0;
        ll ans=0;
        while(n--){
            cin>>num;
            if(num>pre){
                ans+=(num-pre)*6+5;
                pre=num;
            }
            else {
                ans+=(pre-num)*4+5;
                pre=num;
            }
        }
        cout<<ans<<endl;
    }
    getchar();
    getchar();
    return 0;
}
